package pl.smath.renderer.model.sign;

import gwt.g2d.client.graphics.Surface;
import gwt.g2d.client.graphics.canvas.Context;
import pl.smath.renderer.utils.Cursor;

public class DivisionSign extends AbstractSign {

	public DivisionSign() {
		super();
	}

	/**
	 * render the sign on the surface
	 */
	@Override
	public void render(Surface canvas, Cursor cursor) {
		Double length = this.getSignWidth();
		Double x = cursor.getX() + this.getSpace() + length/2;
		Double y1 = cursor.getY() - this.getFontHeight() * 0.2d + length/4;
		Double y2 = cursor.getY() - this.getFontHeight() * 0.5d + length/4;
		
		Context ctx = canvas.getContext();
		//draw a circle
		ctx.beginPath();
		ctx.arc(x, y1, length, 0, Math.PI*2, true);
		ctx.arc(x, y2, length, 0, Math.PI*2, true);
		ctx.closePath();
		ctx.fill();
		
	}
	
	/**
	 * update the width and height
	 */
	@Override
	public void update() {
		this.setSignWidth(this.getFontHeight() * 0.075d);
		this.setWidth(this.getSignWidth() + 2d * this.getSpace());
		this.setHeight(this.getFontHeight());
	}

}
